home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
Regex
/
src
/
Regex.h
< prev
Wrap
C/C++ Source or Header
|
1991-06-14
|
2KB
|
58 lines
#ifndef RJS_REGEX_CLASS_H
#define RJS_REGEX_CLASS_H
#include <RJS/String.h>
struct re_pattern_buffer;
struct re_registers;
class RJS_Regex : public RJS_StringSearch, private RJS_String {
protected:
re_pattern_buffer *buf;
re_registers *reg;
char *compile_error; // the error message if any
int changed;
void initialize(const char* t, int tlen, int fast,
int bufsize, const char* transtable);
public:
RJS_String &Str() { return RJS_String::Str(); }
void update() { changed=1; }
RJS_Regex();
RJS_Regex(const RJS_Regex &r);
RJS_Regex(const char* t, int fast = 0, int bufsize = 40,const char *tt = 0);
RJS_Regex(const RJS_String& x,int fast = 0,int bufsize = 40, const char *tt = 0);
~RJS_Regex();
void operator=(const RJS_Regex &r);
void operator=(const char *s);
void operator=(const RJS_String &s);
int compile();
int match(const char* s, int len = -1, int pos = 0) const;
int match(const RJS_String &s) const;
int search(const char* s,int &matchlen, int len = -1,int startpos = 0) const;
int search(const RJS_String &s, int &matchlen) const;
int match_info(int& start, int& length, int nth = 0) const;
char *error() const { return compile_error; }
int ok() const;
operator void *() { return (void *) ok(); }
};
// some built in regular expressions
extern const RJS_Regex RXwhite; // = "[ \n\t\r\v\f]+"
extern const RJS_Regex RXoptwhite; // = "[ \n\t\r\v\f]*"
extern const RJS_Regex RXnonwhite; // = "[^ \n\t\r\v\f]+"
extern const RJS_Regex RXint; // = "-?[0-9]+"
extern const RJS_Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\|
// \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)
// \\([eE][---+]?[0-9]+\\)?"
extern const RJS_Regex RXalpha; // = "[A-Za-z]+"
extern const RJS_Regex RXlower; // = "[a-z]+"
extern const RJS_Regex RXupper; // = "[A-Z]+"
extern const RJS_Regex RXalphanum; // = "[0-9A-Za-z]+"
extern const RJS_Regex RXid; // = "[A-Za-z_][A-Za-z0-9_]*"
extern const RJS_Regex RXstr; // = "\"[^\"]\""
extern const RJS_Regex RXstrq; // = "\"\\([^\"\\]\\|\\\\\"\\|\\\\\\)*\""
#endif